home *** CD-ROM | disk | FTP | other *** search
-
- /*
- ** RedGreenInvert walks a 32-bit GWorld and inverts the red and green channels.
- */
-
- #include "DemoRoutines.h"
-
- void RedGreenInvert( GWorldPtr src )
- {
- PixMapHandle srcPixMap;
- short srcRowBytes;
- long *srcBaseAddr;
- long *srcAddr1;
- short mmuMode;
- short row, column;
- short width;
- short height;
- GDHandle oldGD;
- GWorldPtr oldGW;
-
- srcPixMap = GetGWorldPixMap ( src );
-
- if( LockPixels ( srcPixMap ) )
- {
- GetGWorld(&oldGW,&oldGD);
-
- srcBaseAddr = (long *) GetPixBaseAddr ( srcPixMap ); /* get the address of the pixmap */
- srcRowBytes = (**srcPixMap).rowBytes & 0x7fff; /* get the row increment */
- width = (**srcPixMap).bounds.right-(**srcPixMap).bounds.left;
- height = (**srcPixMap).bounds.bottom-(**srcPixMap).bounds.top;
-
- mmuMode = true32b;
- SwapMMUMode ( &mmuMode ); /* set the MMU to 32-bit mode */
- for ( row = 0; row < height; row++ )
- {
- srcAddr1 = srcBaseAddr;
- for ( column = 0; column < width; column++ )
- {
- *srcAddr1 ^= 0x00ffff00; /* invert the red and green */
- srcAddr1++; /* bump to next pixel */
- }
-
- srcBaseAddr = (long *) ( (char *) srcBaseAddr + srcRowBytes ); /* go to the next row */
- }
- SwapMMUMode ( &mmuMode ); /* restore the previous MMU mode */
- UnlockPixels ( srcPixMap ); /* unlock the pixmap */
- }
- }
-